﻿using ServiceStack.Common.Extensions;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Web;

namespace d1Project.Modules.Business.doXZ.Domain
{
    /// <summary>
    /// 薪酬
    /// </summary>
    public class XZ_Salary
    {

        public double XZ_Zws(XZ_GswhHelper helper)
        {
            double s = 0;
            double y = 0;
            doXZDbContext db = new doXZDbContext();
            try
            {
                var entity = db.XZ_Gswh.OrderBy(x=>x.Name).AsQueryable();
                if (entity != null)
                {
                    Type t = helper.GetType();
                    PropertyInfo[] PropertyList = t.GetProperties();
                    foreach (PropertyInfo item in PropertyList)
                    {
                        string name = item.Name;
                        object value = item.GetValue(helper, null);
                        double num = 0;
                        if (entity != null)
                        {
                            var en = entity.Where(x => x.Name == name).FirstOrDefault();

                            if (en != null)
                            {
                                num = en.Num;
                            }
                        }
                        if (value != null)
                        {
                            s = js(s, Convert.ToDouble(value), num);
                        }

                    }
                    y = XZ_Jbsf.Instance.Power(Math.E, 8.1+s);
                }
            }
            finally
            {
                db.Dispose();
            }
            return y;
        }
        
        public double js(double s, double x, double a)
        {
            s += + a * x;
            return s;
        }

        public double XZ_Gws(XZ_GswhHelper helper)
        {
            double reslut;
            double x = 1.7 *XZ_Zws(helper);
            reslut = x - 72.07;
            return reslut;
        }
        public double XZ_Dws(XZ_GswhHelper helper)
        {
            double reslut;
            double x = 0.5 * XZ_Zws(helper);
            reslut = x + 72.07;
            return reslut;
        }
    }
}